1. Field of the Invention
The present invention relates to storage devices which manage nonvolatile semiconductor memories, and more particularly to a storage device which converts a logical address to a physical address of a nonvolatile semiconductor memory for management of the nonvolatile semiconductor memory.
2. Description of the Background Art
Of various nonvolatile semiconductor memories, a NAND-type flash memory has recently become widespread as one for mass data storage. With the NAND-type flash memory, data are erased in a unit of block that is formed of a plurality of pages, and are written only in a unit of page for a page having data erased therefrom.
In a conventional storage device formed of such a NAND-type flash memory, if a user wishes to rewrite data of one page, he/she cannot write data directly to the relevant page. It is necessary to erase data on the page before writing of new data, or to write the new data to a page in another block having data erased therefrom.
Japanese Patent Laying-Open No. 2001-142774 discloses a related technique, i.e., an address converting method which makes it unnecessary to increase a nonvolatile memory area for an address converting table even when the storage capacity of a rewritable nonvolatile memory increases.
The conventional storage device formed of the above-described NAND-type flash memory is disadvantageous in that, when new data is to be written after erasing data on the relevant page, the data must be erased on the block basis. This means that data on pages other than the relevant page should be saved before data erasing; otherwise, the data on the pages other than the relevant page would also be erased. As such, the rewriting of the data to the relevant page would take a long time, leading to degradation in processing speed of the processor.
In the case where data is to be written into another block having data erased therefrom, address management becomes necessary to make sure data in which area is written on what number of page in which block. It is also necessary to manage information indicating that the page which originally stored the data is now invalid. As such, updating of the management information associated with the data rewriting would become complicated, and the amount of the management information would also increase.
Further, although the address converting method disclosed in Japanese Patent Laying-Open No. 2001-142774 converts a logical address to a physical address of a flash memory, it cannot solve the above-described problems, since it does not take account of data rewrite based on data erase in units of blocks.
An object of the present invention is to provide a storage device which permits rapid rewriting of user data in a nonvolatile semiconductor memory.
According to an aspect of the present invention, the storage device includes a nonvolatile semiconductor memory having data erased in a unit of block that is formed of a plurality of pages and written in a unit of page for a page having data erased therefrom, and a control portion controlling the nonvolatile semiconductor memory.
The nonvolatile semiconductor memory includes a user block for storage of the user data, an alternate block reserved for substitution, a conversion table for storage of a physical address of the user block corresponding to a logical address, and an alternate table for storage of a physical address of the alternate block.
The control portion refers to the conversion table for writing the user data to a page within the user block. At this time, if the relevant page has data written therein, the control portion refers to the alternate table and writes the user data to a page within the alternate block. The alternate block is now used as a new user block, and the original user block is used as the alternate block. This enables rapid rewriting of the user data.